﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SdlDotNet.Graphics;
using SdlDotNet.Graphics.Sprites;
using SdlDotNet.Graphics.Primitives;
using Point = System.Drawing.Point;

namespace Pokemon
{
    public class Atom
    {
        public AnimatedSprite Image;
        int _xPos;
        int _yPos;
        int xPosOld;
        int yPosOld;
        int _Layer;
        int MoveDelay;

        #region Properties

        public int xPos
        {
            get
            {
                return _xPos;
            }
            set
            {
                _xPos = Math.Min(Math.Max(value, 0), int.MaxValue);
            }
        }

        public int yPos
        {
            get
            {
                return _yPos;
            }
            set
            {
                _yPos = Math.Min(Math.Max(value, 0), int.MaxValue);
            }
        }

        public int Layer
        {
            get
            {
                return _Layer;
            }
            set
            {
                _Layer = Math.Min(Math.Max(value, int.MinValue), int.MaxValue);
            }
        }

        #endregion

        public bool Move(int ox, int oy)
        {
            if (MoveDelay <= 0)
            {
                xPos += ox;
                yPos += oy;
                MoveDelay = 4;

                return true;
            }

            return false;
        }

        public void Update()
        {
                /*
            int xStep = (xPosNew - xPos) / Math.Abs(xPosNew - xPos);
            int yStep = (yPosNew - yPos) / Math.Abs(yPosNew - yPos);
            xPos += xPos != xPosNew ? xStep : 0;
            yPos += yPos != yPosNew ? yStep : 0;
            */

            MoveDelay--;
        }

        public void Draw(int ox, int oy)
        {
            Global.MainSurface.Blit(Image, new Point(ox, oy));
        }
    }
}